Skip to content

docs(examples): add createMint runnable example#408

Merged
HealthyBuilder merged 1 commit into
solana-foundation:mainfrom
sonicfromnewyoke:sonic/feat-create-mint-example
Apr 23, 2026
Merged

docs(examples): add createMint runnable example#408
HealthyBuilder merged 1 commit into
solana-foundation:mainfrom
sonicfromnewyoke:sonic/feat-create-mint-example

Conversation

@sonicfromnewyoke
Copy link
Copy Markdown
Contributor

Problem

this is not obvious how to create mints using the SDK

Solution

add runnable example of this functionality

closes #277

Adds rpc/examples/createMint demonstrating the idiomatic way to create
a new SPL Token mint — the two-instruction composition readers have
historically had to reconstruct themselves:

  1. system.CreateAccount allocates 82 bytes funded to the rent-exempt
     minimum, owned by token.ProgramID.
  2. token.InitializeMint2 writes the mint state (decimals, mint
     authority, freeze authority). Mint2 is preferred over Mint because
     Token v1.1+ dropped the Rent sysvar the original required.

The example runs end-to-end on devnet: generate payer + mint keypair,
airdrop, fetch rent via GetMinimumBalanceForRentExemption, build both
instructions, sign with both keypairs (the mint keypair authorizes
creation at its own pubkey), and SendTransaction. Inline comments
point to the Token-2022 variant and note where extensions would slot
in before InitializeMint2.

Closes solana-foundation#277
@HealthyBuilder HealthyBuilder merged commit 5ea9440 into solana-foundation:main Apr 23, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create new token and token-2022

2 participants